package project1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        book book1 =new book(1,"java教程",30.6,30);
        book book2 =new book(2,"jsp教程",42.1,40);
        book book3 =new book(3,"ssh架构",47.3,15);
        book[] arr=new book[]{book1,book2,book3};
        int[] xuhao=new int[100];
        int i=0,j=0,k,a=0,b;
        double sum=0;
        while(true) {
            System.out.println("请输入图书编号选择图书:");
            b = sc.nextInt();
            if(b==-1)
            {
                break;
            }
            System.out.println("请输入购买图书数量:");
            a= sc.nextInt();
            j=0;
            while(j<3)
            {
                if(b==arr[j].getBianhao())
                {
                    arr[j].mai=a;
                    arr[j].cost(a);
                    xuhao[i++]=j;
                }
                j++;
            }
            System.out.println("请继续,输入-1终止");
        }
        xuhao[i]=-1;
        i=0;
        System.out.println("        图书订单");
        System.out.println("图书名称  购买数量  图书单价");
        while(xuhao[i]!=-1)
        {
            System.out.println(arr[xuhao[i]].getName()+"  "+arr[xuhao[i]].mai+"        "+arr[xuhao[i]].getPrice());
            sum=sum+arr[xuhao[i]].getPrice()*arr[xuhao[i]].mai;
            i++;
        }
        System.out.println("购买总额："+(float)sum);
    }
}
